<template>
    <view>
		<!-- <view class="img2">lkajsflkfjs</view> -->
		<gz-image-rotate ref="gzImageRotate" @success="success"></gz-image-rotate>
    
		<image class="img2" src="../../static/images/fontDirection.png"></image>
		<view>
			<htz-signature class="sign" @sumbit="sumbit"  @fail="fail" cid="ceshi1"></htz-signature>
		</view>
    </view>
</template>
<script>
    import htzSignature from '@/components/htz-signature/htz-signature.vue'
	import gzImageRotate from '@/components/gz-image-rotate/gz-image-rotate.vue'
    
    export default {
        data() {
            return {
				
            }
        },
        components: {
            htzSignature,
			gzImageRotate,
        },
        mounted() {
            this.$nextTick(function() {
            });
        },
		onLoad(option) {
			console.log('onLoad option -------------- ', option);
			this.option = option;
			
			if(0){
				uni.showModal({
					title: '注意事项',
					content: '为了报名成功, \r\n需要横向的手写电子签名! \r\n签名前请将手机先横过来.',
					// confirmText: "否", 
					showCancel: false,
					
					cancelText: "是",
					success: function(res) {
						console.log('~~~~~~~~~~~ success ', res);
						return
					},
					fail: function(res) {
						console.log('!!!!!!!!!!!!! fail', res);
					}
				});
			}
		},
		
        methods: {  
			success(e){
				console.log('******* e.tempFilePath', e.tempFilePath)
				// uni.saveImageToPhotosAlbum({
				//  filePath:e.tempFilePath
				// })
			},
            sumbit(res){
                console.log('sumbit',res);
                try {
					/* 返回调用页面并把图片URL传递过去 */
					let pages = getCurrentPages();
					let prevPage = pages[pages.length - 2]; 
					let key = this.option.key;
					if(!key)
						key = 'aaaaaaaaaaaa';
					var dc = {[key]: res.tempFilePath};
					console.log('dc ~~~~~~~ ', dc);
					let that = this;
					
					// that.$refs.gzImageRotate.start(res.tempFilePaths[0], 3);
					console.log("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1")
					console.log('that.$refs.gzImageRotate', that.$refs.gzImageRotate)
					console.log("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2")
					console.log('that.$refs.gzImageRotate.start', that.$refs.gzImageRotate.start)
					console.log("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3")					
					this.$refs.gzImageRotate.start(res.tempFilePath, 3);
					// console.log('this.$refs.gzImageRotate.start(res.tempFilePaths[0], 3)')
					
					console.log('prevPage   === ', prevPage);
					if(prevPage)
						prevPage.setData(dc);
					
					/* 调用页面获取图片URL方法 */
					/* let pages = getCurrentPages();
					let currPage = pages[pages.length-1];
					if(typeof(currPage.data.image) != undefined && currPage.data.image != null){
						console.log('获取图片：', currPage.data.image)
					} */
					
					
					// // --------- 用缓存传参
					// uni.setStorageSync('ceshiUrl', res.tempFilePath);
					// // uni.getStorageSync('ceshiUrl');
					
                    uni.navigateBack();
                } catch (e) {
                    // error
					console.log('catch e ~~~~~~~~~', e)
                }
            },
            fail(err){
                console.log('fail --------', err)
            },
        }
    }
</script>

<style lang="scss">  
	
  // .img2{
	 //  // width: 100upx;
	 //  height: 120upx;
	 //  // float: left;
  // }
  // .sign{
	 //  background-image: "../../static/htz-signature/chehuinormal.png"
  // }
  .img2{
  	// position:absolute;
	// width: 100upx;
	height: 120upx;
  	z-index:2;
	// opacity: 0.5;
	// transform:rotate(90deg);
  }
</style> 
  